package com.neusoft.elmboot.mapper;

import com.neusoft.elmboot.po.Orders;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface OrdersMapper {
    //@Insert("insert into orders(userId,businessId,orderDate,orderTotal,daId,orderState,discount,orderDel,orderTime) values(#{userId},#{businessId},#{orderDate},#{orderTotal},#{daId},0,#{discount},0,#{orderTime})")
	@Insert("insert into orders(userId,businessId,orderDate,orderTotal,daId,orderState,discount,orderDel) values(#{userId},#{businessId},#{orderDate},#{orderTotal},#{daId},0,#{discount},0)")
	//@Insert("insert into orders(userId,businessId,orderDate,orderTotal,daId,orderState) values(#{userId},#{businessId},#{orderDate},#{orderTotal},#{daId},0)")

	@Options(useGeneratedKeys=true,keyProperty="orderId",keyColumn="orderId")
    public int saveOrders(Orders orders);
    public Orders getOrdersById(Integer orderId);
    public List<Orders> listOrdersByUserId(String userId);
    public List<Orders> listOrdersByBusinessId(Integer businessId);
    @Update("update orders set orderDel = '1' where  orderId=#{orderId}")
    public  int removeOrder(Integer orderId);
    
    @Update("update orders set orderState = '1' where  orderId=#{orderId}")
    public int updateOrdersState(Integer orderId);
    
}
